// ***********************************************
// >> File Name: /home/diabio/project/al_cache/test/test.cpp
// >> Author: diabiolin
// >> Created Time: Wed 16 Apr 2025 04:04:57 PM CST
// >> Description:
// ***********************************************
#include "cache_algorithm_tester.h"
#include "fifo_cache.h"
#include "lru_cache.h"
#include "lfu_cache.h"
#include "arc_cache.h"

int main(){
	using namespace al_cache;
	// 测试参数
	int capacity = 50;  // 缓存容量 
	int numOperaitons = 2000000;  // 操作次数 
	std::vector<int> threadCounts = {256};  // 要测试的线程数量 
	std::vector<std::string> dataTypes = {"hot"};  // 要测试的数据类型 （hot， loop_scan， workload_change）
	bool usingSimulationDataSources = true; // 是否使用模拟读取数据源操作 ，单线程建议不启用

	// 创建缓存实例
	FifoCache<int, int> fifoCache(capacity);
	LruCache<int, int> lruCache(capacity);
	LruKCache<int, int> lruKCache(capacity, 75, 3);
	LfuCache<int, int> lfuCache(capacity, 10);
	HashLruCache<int, int> hashLruCache(capacity, 10);
	HashLruKCache<int, int> hashLruKCache(capacity, 75, 10, 3);
	HashLfuCache<int, int> hashLfuCache(capacity, 10, 10);
	ArcCache<int, int> arcCache(25);
	// 创建包含缓存实例和算法名的向量
	std::vector<std::pair<std::reference_wrapper<CachePolicy<int, int>>, std::string>> caches = {
		{std::ref(fifoCache), "FIFO"},
		{std::ref(lruCache), "LRU"},
		{std::ref(lruKCache), "LRU-K"},
		{std::ref(hashLruCache), "HASH-LRU"},
		{std::ref(hashLruKCache), "HASH-LRU"},
		{std::ref(lfuCache), "LFU"},
		{std::ref(hashLfuCache), "HASH-LFU"},  
		{std::ref(arcCache), "ARC"}
	};   

	// 创建缓存算法测试器实例
	CacheAlgorithmTester<int, int, CachePolicy> tester(capacity, numOperaitons, threadCounts, dataTypes,usingSimulationDataSources, caches);

	// 运行所有测试场景 
	tester.runAllTests();

	return 0;
}
